const validateProductCode= (rule, value, callback) => { //产品编码校验
  let codeReg = /^[A-Za-z0-9\-]+$/;
  if(!codeReg.test(value)){
    callback(new Error('产品编号只能包含“英文字母、数字和-”！'));
    // isContinue = false;
  } else {
    callback();
  }
};

let status = {
  modalAddByCrawler:{
    isShow :false,
    isParsed:false
  },
  rules: {
    productCode: [
      {required: true, message: '产品编号不能为空', trigger: 'blur'},
      {validator: validateProductCode, trigger: 'change'}
    ],
    classificationIds: [
      {validator:(rule, value, callback)=>{
        if(value.length<=0){
          callback(new Error('请选择产品分类！'));
          // isContinue = false;
        }else{
          callback();
        }
        }, trigger: 'change'}
    ],
    sysSizeType:[
      {required: true, type: 'number',message: '产品尺码类型不能为空', trigger: 'change'}
    ]
  }
};

// 页面的数据源
let data = {
  //编辑详情的色卡
  allSysSize: [],
  classificationTreeShow:[],
  classificationList:[],
  classificationTree:[],
  crawlerAttrs:[],
  carwlerData:""
};

let params = {
    //新增
    paramProduct: {
      // productName: '',
      productCode: '',
      classificationIds:[],
      sysSizeType:'',
    },
    crawler:{
      sourceUrl:"",
      title:"",
      shippingFee:"",
      colors:[],
      prices:[],
      attrs:[],
      imgs:[]
    }
};

let attrTable = function (self) {
  return [
    {
      type: 'selection',
      width: 60,
      fixed: 'left',
      align: 'center',
    },
    {
      type: 'index',
      title: '#',
      width: 60,
      key: 'index',
      fixed: 'left',
      align: 'center',
    },
    {
      title: '属性名',
      key: 'name',
      width:  200,
      align: 'center'
    },
    {
      title: '属性值',
      key: 'value',
      align: 'center'
    }
  ];
};

export  default  {
  tStatus: status,
  tParam: params,
  tData: data,
  attrTable:attrTable
};

